<template>
  <div class="app-container">
    <el-card class="box-card">
      <h3 class="title-left">维修基本信息</h3>
      <el-divider style="border-width: thin"></el-divider>
      <el-button @click="returnUp" class="retu">返回</el-button>
      <div style="padding-left: 130px">
        <el-descriptions>
          <el-descriptions-item label="维修编号">{{ rno }}</el-descriptions-item>
          <el-descriptions-item label="维修申请人">{{ repairApplicant }}</el-descriptions-item>
          <el-descriptions-item label="维修数量">{{ repairCount }}</el-descriptions-item>
          <el-descriptions-item label="维修费用">{{ repairWages }}元</el-descriptions-item>
          <el-descriptions-item label="维修申请日期">{{ repairAppdate }}</el-descriptions-item>
          <el-descriptions-item label="维修日期">{{ repairDate }}</el-descriptions-item>
          <el-descriptions-item label="审批状态">
              <dict-tag :options="dict.type.sys_repair_status" :value="status"/>
          </el-descriptions-item>
        </el-descriptions>
      </div>

    </el-card>
    <el-card class="box-card" style="margin-top: 10px">
      <h3 class="title-left">维修清单</h3>
      <el-divider style="border-width: thin"></el-divider>
      <el-table v-loading="loading" :data="detailList">
        <el-table-column width="55" align="center" />
        <el-table-column label="序号" type="index" :index="indexMethod" align="center"/>
        <el-table-column label="资产名称" align="center" prop="name" />
        <el-table-column label="资产类别" align="center" prop="type" />
        <el-table-column label="配件品牌" align="center" prop="brand" />
        <el-table-column label="维修原因" align="center" prop="reason" />
      </el-table>
    </el-card>

    <el-card class="box-card" style="margin-top: 10px">
      <h3 class="title-left">附件</h3>
      <el-divider style="border-width: thin"></el-divider>

    </el-card>
  </div>
</template>
<style>
.title-left{
  position: relative;
  padding-left: 13px;
  margin: 2px 0
}
.title-left:before{
  content: "";
  background-color: #3796EC;
  width: 5px;
  height: 17px;
  position: absolute;
  left: 5px;
  top: 45%;
  margin: -8px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}
.retu{
  position: relative;
  top: -10px;
}
</style>
<script>
import { getDetail} from "@/api/system/repairDetail";
import { getRepair } from '@/api/system/repair'

export default {
  name: "Detail",
  dicts: ['sys_repair_status'],
  data() {
    return {
      detailList:[],
      loading:null,
      rno:'',
      repairDate:'',
      repairCount:'',
      repairWages:'',
      repairAppdate:'',
      status:'',
      repairApplicant:'',
    };
  },
  created() {
    const repairId = this.$route.params && this.$route.params.id;//维修id
    this.getList(repairId);
  },
  methods: {
    /** 查询维修详情表列表 */
    getList(repairId) {
      this.loading = true;
      getRepair(repairId).then(res => {
        this.repairDate = res.data.repairDate;
        this.rno = res.data.rno;
        this.repairCount = res.data.repairCount;
        this.repairWages = res.data.repairWages;
        this.status = res.data.status;
        this.repairApplicant = res.data.repairApplicant;
        this.repairAppdate = res.data.repairAppdate;
        //给维修清单赋值
        this.detailList = res.data.repairDetailList;
        this.loading = false;
      });
    },
    returnUp(){
      /* const obj = { path: "/logistics/repairDetail" };
      this.$tab.closeOpenPage(obj); */
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getDetail(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改维修详情表";
      });
    },
    indexMethod(index) {
      return index + 1;
    }
  }
};
</script>
